home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BCI NET
/
BCI NET Dec 94.iso
/
archives
/
telecomm
/
bbs
/
maxsdoors2.lha
/
Amigastats.lha
/
AmigaStats.bas
< prev
next >
Wrap
BASIC Source File
|
1992-11-11
|
7KB
|
252 lines
'no window
REM $OPTION Y
'Open the libraries we will need
LIBRARY "exec.library"
LIBRARY "dos.library"
LIBRARY "intuition.library"
'and declare the functions we'll need
DECLARE FUNCTION AllocMem& LIBRARY
DECLARE FUNCTION FreeMem& LIBRARY
DECLARE FUNCTION FindTask& LIBRARY
DECLARE FUNCTION AllocSignal& LIBRARY
DECLARE FUNCTION AddPort& LIBRARY
DECLARE FUNCTION Forbid& LIBRARY
DECLARE FUNCTION Permit& LIBRARY
DECLARE FUNCTION FindPort& LIBRARY
DECLARE FUNCTION PutMsg& LIBRARY
DECLARE FUNCTION WaitPort& LIBRARY
DECLARE FUNCTION GetMsg& LIBRARY
DECLARE FUNCTION RemPort& LIBRARY
DECLARE FUNCTION FreeSignal& LIBRARY
ON ERROR GOTO error.handler
'And set up the variables we'll need as global
DIM SHARED PortAddress&, TaskAddr&, Dummy%, MsgPortName$, MsgPortName2$
DIM SHARED Sig%, ControlPort&, ErrCode%, Arg1&, Arg2&, Reply&
DIM SHARED i&, j%, Flag%, esc$, a%, L&, NameMemAddr&
'=================================================================
IF COMMAND$="" THEN
WINDOW 1,"AmigaStats",(0,0)-(300,100),22
PRINT "Major problems: couldn't get the node number from the BBS!!"
ErrCode%=1
GOTO Exitt
END IF
'OK, so now we define the portnames, with terminating zeros
trick:
MsgPortName$="DoorControl"+COMMAND$+CHR$(0)
MsgPortName2$="DoorReply"+COMMAND$+CHR$(0)
CALL GetPort
IF ControlPort&=0 THEN
WINDOW 1,"AmigaStats",(0,0)-(300,100),22
PRINT "Can't find the BBS's control port! Exiting ...."
ErrCode%=4
END IF
IF ErrCode% <> 0 THEN GOTO Exitt
'######################################################################
'Your Programme goes in here!!!!!
'######################################################################
cr$ = CHR$(13)
ff$ = CHR$(12)
Call Printstring(ff$+cr$)
If Command$ = "0" Then exitt 'Quit if logged in locally....
Call Hotkey(cr$+"
Would you like to see some stats on Murray's Computer? <Y/n>
",X%)
X$ = UCASE$(CHR$(X%))
IF X$ = "N" Then
Call Printstring("No!")
Goto Exitt
Else
Call Printstring("Yes!")
Call DoMenu(27,0,"Execute S:Stats")
Call Printfile("BBS:Text/AmigaStats.text")
Call Printstring(FF$)
End If
'######################################################################
'And ENDS Here!
'######################################################################
Exitt:
CALL FreePort
LIBRARY CLOSE
SYSTEM
Error.Handler:
St$=CHR$(13)+CHR$(27)+"[31mThere has been a problem with the proggy!!!"+CHR$(13)
CALL PrintString(St$)
St$="Please notify %a!!"+CHR$(13)+CHR$(13)
CALL PrintString(St$)
St$=CHR$(27)+"[32mPress any key to continue..."
CALL Hotkey("",X%)
'don't attempt to free the memory - we don't know where the error was!
GOTO exitt
SUB getport STATIC
'sub to determine if MAX'sBBS message port exists &, if it does, to open
'a reply port for it
'First, allocate the memory we need for msgport etc
PortAddress&=AllocMem&(140&,&H10001)
IF PortAddress&=0 THEN
WINDOW 1,"AmigaStats Error Window",(0,0)-(300,100),22
PRINT "Couldn't allocate the memory!"
ErrCode%=2
GOTO Out
END IF
'Now, find our task structure
TaskAddr&=FindTask&(0)
'and put it in the messageport structure
POKEL PortAddress&+16,TaskAddr&
'now, allocate a signal bit
Sig% = AllocSignal&(-1)
IF Sig%<0 THEN
ErrCode%=3
GOTO Out
END IF
'and do some setups
POKE PortAddress&+8,4
POKEL PortAddress&+10,SADD(MsgPortName2$)
POKE PortAddress&+15,Sig%
POKE PortAddress&+42,5
POKEW PortAddress&+52,106
POKEL PortAddress&+48,PortAddress&
'and add our msgport to the system
Reply&=AddPort&(PortAddress&)
'now, let's find MAX'sBBS port
Dummy%=Forbid&
ControlPort&=FindPort&(SADD(MsgPortName$))
Dummy%=Permit&
'ok, that's enough for now. Lets go back
Out:
END SUB
SUB FreePort STATIC
'Was there an error & if so, what do we do?
IF ErrCode% = 1 THEN GOTO Sig1
IF ErrCode% = 2 THEN GOTO Sig2
IF ErrCode% = 3 THEN GOTO Sig3
IF ErrCode% = 4 THEN GOTO Sig4
'OK. Either we're finished or the carrier has been lost (& we're
'still finished)
CALL GetMsgPrt (Arg1&,Arg2&)
POKEW Arg2&,20 'This is the command we're passing
'now we put the message into the message queue
Reply&=PutMsg&(ControlPort&,Arg1&)
'and wait for a reply
Pause:
Reply&=WaitPort&(PortAddress&)
Reply&=GetMsg&(PortAddress&)
IF Reply&=0 THEN GOTO Pause
Sig4: 'General cleanup routine
Dummy%=RemPort&(PortAddress&) 'free the messageport
Dummy%=PEEK(PortAddress&+15) 'get the signal number
Dummy%=FreeSignal&(Dummy%) 'and frre the signal
Sig3:
Dummy%=FreeMem(PortAddress&,140&)
Sig2:
Sig1:
END SUB
SUB GetMsgPrt(Arg1&, Arg2&) STATIC
'this little routine sets up the pointers for messaging
'Arg1& corresponds to register A1, which is the passed to the PutMsg&
'function.
Arg1&=PortAddress&+34
Arg2&=PortAddress&+54
POKEL Arg2&+2,0
END SUB
SUB PrintString(St$) STATIC
'routine to print a text string
CALL GetMsgPrt (Arg1&, Arg2&)
POKEW Arg2&,1 'command number
POKEW Arg2&+2,0 'terminating null
FOR i&=1 TO LEN(St$)
POKE Arg2&+3+i&,ASC(MID$(St$,i&,1)) 'put the string in
NEXT
POKE Arg2&+3+i&,0
CALL PutWaitMsg
END SUB
SUB PutWaitMsg STATIC
'routine to put the message to the port & await a reply
LOCAL Temp&, Locn&, Tempp&
Reply&=PutMsg&(ControlPort&,Arg1&)
'and wait for a reply
Pause1:
Reply&=WaitPort&(PortAddress&)
Reply&=GetMsg&(PortAddress&)
IF Reply&=0 THEN GOTO Pause1
Tempp&=PEEKW(Reply&+24&+80&)
IF Tempp&<>0 THEN GOTO Exitt 'lost carrier
END SUB
SUB PrintFile(F$) STATIC
'routine to print a text file
CALL GetMsgPrt (Arg1&, Arg2&)
POKEW Arg2&,10 'command number
POKEW Arg2&+2,0 'terminating null
FOR i&=1 TO LEN(F$)
POKE Arg2&+3+i&,ASC(MID$(F$,i&,1)) 'put the string in
NEXT
POKE Arg2&+3+i&,0
CALL PutWaitMsg
END SUB
SUB hotkey (F$,K%) STATIC
'routine to print a string & get any keypress
CALL GetMsgPrt (Arg1&, Arg2&)
POKEW Arg2&,8 'command number
POKEW Arg2&+2,0 'terminating null
FOR i&=1 TO LEN(F$)
POKE Arg2&+3+i&,ASC(MID$(F$,i&,1)) 'put the string in
NEXT
POKE Arg2&+3+i&,0
CALL PutWaitMsg
K%=PEEK(Arg2&+4)
END SUB
SUB UserInfo2(St$,Which%) STATIC
'Routine to get (numerical) user / system details
CALL GetMsgPrt (Arg1&, Arg2&)
POKEW Arg2&,13 'command number
POKEW Arg2&+2,Which%
CALL PutWaitMsg
st$=STR$(PEEKW(Arg2&+2))
END SUB
SUB DoMenu(A,B,F$) STATIC
'call a maxsBBS menu function
CALL GetMsgPrt (Arg1&, Arg2&)
POKEW Arg2&,A+100 ' command number
POKEW Arg2&+2,B ' subcommand
FOR i&=1 TO LEN(F$)
POKE Arg2&+3+i&,ASC(MID$(F$,i&,1)) 'put the string in
NEXT
POKE Arg2&+3+i&,0
CALL PutWaitMsg
END SUB